﻿using DemoForBillOcr;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BillHelper
{
    public partial class test : Form
    {
        public test()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            List<HighSpeedRailTicket> hsrtList = new List<HighSpeedRailTicket>();
            List<HighSpeedRailTicket> hsrtLisst = new List<HighSpeedRailTicket>();
            HighSpeedRailTicket hsrt = new HighSpeedRailTicket();
            string tpresult = "";
            string apiurl2 = ApiUrlList.GETDATAALL;
            string apiurlGT = ApiUrlList.GETHSRTINFO;
            string result = "";
            hsrt.invoiceId = 0;
            result = RestDataTool.PostGT(out tpresult, hsrt, apiurlGT, out hsrtList);
            hsrtLisst = hsrtList;
            if (hsrtList.Count > 0)
            {
                setHSRTList(hsrtList[0]);
            }
            else {
                hsrt = null;
                setHSRTList(hsrt);
            }
           
        }
        private void setHSRTList(HighSpeedRailTicket hsrt) {
            if (hsrt!=null) {
                startStation.Text = hsrt.startStation;
                trainNumber.Text = hsrt.trainNumber;
                endStation.Text = hsrt.endStation;
                startDate.Text = hsrt.startDate;
                startTime.Text = hsrt.startTime;
                seat.Text = hsrt.seat;
                ticketPrice.Text = hsrt.ticketPrice;
                searType.Text = hsrt.searType;
                name.Text = hsrt.name;
                idNumber.Text = hsrt.idNumber;
                number.Text = hsrt.number;
            } else {
                startStation.Text = "";
                trainNumber.Text = "";
                endStation.Text = "";
                startDate.Text = "";
                startTime.Text = "";
                seat.Text = "";
                ticketPrice.Text = "";
                searType.Text = "";
                name.Text = "";
                idNumber.Text = "";
                number.Text = "";
            }

        }
    }
}
